﻿using System;
using System.Collections;
using Huirui.Cavan.Domain.MainBoundedContext.SystemModule;
using Huirui.Cavan.Domain.Seedwork;
using System.Collections.Generic;

namespace Huirui.Cavan.Domain.MainBoundedContext.PurchaseModule
{
    public class Pay : Persistent<string>
    {
        #region Member Variables

        protected DateTime _payDate;
        protected Account _fromAccount;
        protected string _accountNumber;
        protected decimal _amount;
        protected decimal _discount;
        protected string _currency;
        protected decimal _currencyRate;
        protected string _remark;
        protected Corporation _corporation;
        protected Employee _payEmployee;
        protected Supplier _supplier;
        protected UserAccount _producer;
        protected IList<PayDetail> _payDetails;


        #endregion

        #region Constructors

        public Pay() 
        {
            this._supplier = new Supplier();
            this._payDate = DateTime.Now;
        }

        public Pay(string id, DateTime payDate, Account fromAccount, string accountNumber, decimal amount, decimal discount, string currency, decimal currencyRate, string remark, DateTime createDate, DateTime modifyDate, UserAccount editUser, Corporation corporation, Employee payEmployee, Supplier supplier)
        {
            this.Id = id;
            this._payDate = payDate;
            this._fromAccount = fromAccount;
            this._accountNumber = accountNumber;
            this._amount = amount;
            this._discount = discount;
            this._currency = currency;
            this._currencyRate = currencyRate;
            this._remark = remark;
            this._createDate = createDate;
            this._modifyDate = modifyDate;
            this._producer = editUser;
            this._corporation = corporation;
            this._payEmployee = payEmployee;
            this._supplier = supplier;
        }

        #endregion

        #region Public Properties


        public virtual DateTime PayDate
        {
            get { return _payDate; }
            set { _payDate = value; }
        }

        public virtual Account FromAccount
        {
            get { return _fromAccount; }
            set { _fromAccount = value; }
        }

        public virtual string AccountNumber
        {
            get { return _accountNumber; }
            set { _accountNumber = value; }
        }

        public virtual decimal Amount
        {
            get { return _amount; }
            set { _amount = value; }
        }

        public virtual decimal Discount
        {
            get { return _discount; }
            set { _discount = value; }
        }

        public virtual string Currency
        {
            get { return _currency; }
            set
            {
                if (value != null && value.Length > 20)
                    throw new ArgumentOutOfRangeException("Invalid value for Currency", value, value.ToString());
                _currency = value;
            }
        }

        public virtual decimal CurrencyRate
        {
            get { return _currencyRate; }
            set { _currencyRate = value; }
        }

        public virtual string Remark
        {
            get { return _remark; }
            set
            {
                _remark = value;
            }
        }

        public virtual Corporation Corporation
        {
            get { return _corporation; }
            set { _corporation = value; }
        }

        public virtual Employee PayEmployee
        {
            get { return _payEmployee; }
            set { _payEmployee = value; }
        }

        public virtual Supplier Supplier
        {
            get { return _supplier; }
            set { _supplier = value; }
        }

        public virtual UserAccount Producer
        {
            get { return _producer; }
            set { _producer = value; }
        }

        public virtual IList<PayDetail> PayDetails
        {
            get 
            {
                if (_payDetails == null)
                {
                    _payDetails = new List<PayDetail>();
                }
                return _payDetails; 
            }
            set { _payDetails = value; }
        }
        #endregion
    }
}
